// a端业务月租费 报文拼接
let packet = {
    // a端业务月租费
    aMonthly(res,ODKInfo,CTOInfo,staffId) {
        let that = this;
        let requestObject = {};
        requestObject.userId = staffId;
        requestObject.custSoNumber = CTOInfo.custSoNumber;
        requestObject.processInstId = ODKInfo.processInstId;
        requestObject.activityId = ODKInfo.activityId;
        requestObject.orderItemId = CTOInfo.orderItemId;
        requestObject.orderItemIds = CTOInfo.orderItemId;
        requestObject.orderAuditId = ODKInfo.orderAuditId;
        requestObject.oneOrmany = "one";
        requestObject.taskId = ODKInfo.taskId;
        requestObject.custId = CTOInfo.custId;
        requestObject.ordOfferInstFeeInfos = that.getOrdOfferInstFeeInfo(res,CTOInfo);
        // 变更日志
        // requestObject.orderItemModifys = that.orderItemModifys(res,CTOInfo);
        // 变更日志明细
        // requestObject.orderItemAttrModifys = that.orderItemAttrModifys(res,CTOInfo);

        return requestObject
    },

    getOrdOfferInstFeeInfo(res,CTOInfo) {
        let ordOfferInstFeeInfo = [];
        res.forEach(function (item, index) {
            let obj = {};
            if (item.tableName == 'ordOfferInstFeeInfos') {
                if(item.colId=="amount"){
                    obj["amount"] = item.value;
                }else{
                    obj["ratio"] = item.value;
                }
                obj["actType"] = item.actType;
                obj["orderItemId"] = CTOInfo.orderItemId;//列表获取
                obj['roleCd'] = item.attrRoleCd;//页面获取
                obj['feeType'] = item.acctItemId;
                obj['currency'] = item.value;//币种
                ordOfferInstFeeInfo.push(obj);
            }

        });
        
        return ordOfferInstFeeInfo
    },
// 变更日志(新老值对比)
    orderItemModifys(res,CTOInfo) {
        let orderItemModifys = [];
        res.forEach(function (item, index) {
            let obj = {};
            if (item.tableName == 'orderItemModifys') {
                obj["actType"] = item.actType;
                obj["attrId"] = item.attrId;
                obj["custOrderId"] = item.custOrderId;
                obj["attrCd"] =item.attrCd;
                obj['oldAttrValue'] = item.oldAttrValue;
                obj['attrValue'] = item.attrValue;
                obj['attrCd'] = item.attrCd;
                obj['roleCd'] = item.roleCd;
                obj['custId'] = item.custId;
                obj['orderItemId'] = CTOInfo.orderItemId;

                orderItemModifys.push(obj);
            }
        });
        return orderItemModifys

    },
    // 变更日志明细
    orderItemAttrModifys(res,CTOInfo){
        let orderItemAttrModifys = [];
        res.forEach(function (item, index) {
            let obj = {};

            if (item.tableName == 'orderItemAttrModifys') {
                obj["actType"] = item.actType;
                obj["custId"] = item.custId;
                obj["statusCd"] =item.statusCd;
                obj["createStaff"] = item.createStaff;;
                obj['roleCd'] = item.roleCd;
                obj['feeType'] = item.feeType;
                obj['currency'] = item.currency;
                orderItemAttrModifys.push(obj);
            }
        });
        return orderItemAttrModifys
    },
    // 确认A端境内方案this.ODKInfo,this.CTOInfo
    confirmaSideOnshoreSolution(res,seletValue,ODKInfo,CTOInfo,user,selectObj){
        let that = this;
        let requestObject = {};

        requestObject.custSoNumber = CTOInfo.custSoNumber;
        requestObject.processInstId = ODKInfo.processInstId;
        requestObject.activityId = ODKInfo.activityId;
        requestObject.orderItemId = CTOInfo.orderItemId;
        requestObject.orderAuditId = ODKInfo.orderAuditId;
        requestObject.taskId = ODKInfo. taskId;
        requestObject.userId =user.staffId;
        requestObject.custId = CTOInfo.custId;


        if(seletValue=="1"){
            requestObject.modProposeItmc = that.modProposeItmc(res,ODKInfo,CTOInfo,user,selectObj);
        }else if(seletValue=="0"){
            requestObject.nomodProposeItmc = that.nomodProposeItmc(res,ODKInfo,CTOInfo,user,selectObj);

        }
        return requestObject

    },
    // 不调整ITMC信息
    nomodProposeItmc(res,ODKInfo,CTOInfo,user,selectObj){
        let noModProposeItmc=[];
        res.forEach(function (item, index) {
            let obj = {};
            
            if (item.tableName == 'noModProposeItmc') {
                obj["orderItemId"] =CTOInfo.orderItemId;
                obj["proposeComment"]=item.proposeComment;
                obj['nodeId'] = selectObj.NODE_ID;
                obj['staffId'] = user.staffId;
                obj['custId'] = item.custId;

                noModProposeItmc.push(obj);
            }

        });
        return noModProposeItmc;
    },
    // 调整ITMC信息
    modProposeItmc(res,ODKInfo,CTOInfo,user,selectObj){
        let modProposeItmc=[];
        res.forEach(function (item, index) {
            
            let obj = {};
            if (item.tableName == 'modProposeItmc') {
                
                obj["locationId"] = selectObj.LOCATION_ID;
                obj["proposeComment"] = item.proposeComment;
                obj['nodeId'] = item.nodeId;
                obj['staffId'] = user.staffId;
                obj['orderItemId'] = CTOInfo.orderItemId;
                obj['nodeName'] = item.nodeName;
                obj['orgId'] = user.orgId;
                obj['custOrderId'] = CTOInfo.custOrderId;
                obj['commonRegionId'] = user.commonRegionId;
                obj['oldAttrValueId'] = selectObj.NODE_ID;
                obj['oldAttrValue'] = selectObj.NODE_NAME;
                obj['custId'] = CTOInfo.custId;
                modProposeItmc.push(obj);
            }
        });
        return modProposeItmc;


    }
}
export default packet
